package fr.raskal.musicalflow.mvc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import fr.raskal.musicalflow.core.Genre;
import fr.raskal.musicalflow.exception.ApplicationException;
import fr.raskal.musicalflow.repo.TopicDao;

@Controller
@RequestMapping(value = "/")
public class TopicController {

	@Autowired
	private TopicDao topicDao;

	@RequestMapping(method = RequestMethod.GET)
	public String displaySortedTopics(Model model) throws ApplicationException {
		model.addAttribute("topics", topicDao.findAll());
		model.addAttribute("genres", Genre.values());
		return "index";
	}

}
